import request from '@/config/axios'

export interface TestOption {
  id?: number
  testId?: number
  orderId: number
  content: string
  picture: string
  correct: boolean
  studentAnswer?: boolean
}

export interface TestGap {
  id?: number
  testId?: number
  orderId: number
  content: string
  score: number
  rule: number
  studentAnswer?: string
}

export interface TestVO {
  id?: number
  type: number | undefined
  score: number
  content: string
  optionCount: number
  testOptions: TestOption[]
  gapCount: number
  testGaps: TestGap[]
  difficulty: number
  knowledgePoint: string
}

// 查询试题列表
export const getTestPage = async (params: PageParam) => {
  return await request.get({ url: `/vr/test/page`, params })
}

// 查询试题详情
export const getTest = async (id: number) => {
  return await request.get({ url: `/vr/test/get?id=` + id })
}

// 新增试题
export const createTest = async (data: TestVO) => {
  return await request.post({ url: `/vr/test/create`, data })
}

// 修改试题
export const updateTest = async (data: TestVO) => {
  return await request.put({ url: `/vr/test/update`, data })
}

// 删除试题
export const deleteTest = async (id: number) => {
  return await request.delete({ url: `/vr/test/delete?id=` + id })
}

// 导出试题 Excel
export const exportTest = async (params) => {
  return await request.download({ url: `/vr/test/export-excel`, params })
}

export const getTestSimpleList = async () => {
  return await request.get({ url: `/vr/test/simple-list` })
}
